<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="img/favicon.ico">

    <title>Jeesoul</title>
    <style>
        /*下面的星号让素有元素内外边距都为0，不留空隙*/
        * {
            padding: 0px;
            margin: 0px;
        }
    </style>
</head>
<body>
<div style="text-align: center; margin-top: 50px;">
    <form id="form" action="" enctype="multipart/form-data" method="post">
        <!--账号：<input type="text" id="username" value="" />
        <br>
        密码：<input type="password" id="password" value="" />
        <br>-->
        <input id="file" type="file" multiple="multiple" style="margin-left: 80px;margin-top: 20px;" />
        <br>
        <input type="button" id="btn" value="提交" />
    </form>
</div>
</body>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://code.jquery.com/jquery.min.js"></script>

<script>
    $(function() {
        $("#btn").click(function() {
            var msg = confirm("确定提交吗？")
            if (msg == false) {
                return;
            }
            var formData = new FormData();
            //formData可以添加额外参数
          /*  formData.append("username", $("#username").val());
            formData.append("password", $("#password").val());*/
            for (var i = 0; i < $('#file')[0].files.length; i++) {
                formData.append('files', $('#file')[0].files[i]);
            }
            $.ajax({
                url: "http://localhost:8000/exportt",
                type: "POST",
                processData: false,
                contentType: "utf-8",
                data: {"file":formData},
                success: function(d) {
                    console.log(d)
                    alert("恭喜您，上传文件成功！")
                },
                error: function() {
                    alert("请求出错啦")
                }
            });

        });

    })
</script>
</html>
